package com.cn.wanxi.service.impl;

import com.cn.wanxi.dao.CompanyDao;
import com.cn.wanxi.dao.impl.CompanyImpl;
import com.cn.wanxi.model.CompanyModel;
import com.cn.wanxi.model.ResultModel;
import com.cn.wanxi.service.CompanyService;
import redis.clients.jedis.Jedis;

public class CompnayServiceImpl implements CompanyService {
    private CompanyDao companyDao = new CompanyImpl();

    @Override
    public ResultModel add(CompanyModel companyModel) {

        int count = companyDao.add(companyModel);
        Jedis jedis = new Jedis();

        if (count > 0) {
            jedis.del("logo", "address");
        }
        return ResultModel.getResultModel(count);
    }

    @Override
    public ResultModel deltete(CompanyModel companyModel) {

        int count = companyDao.delete(companyModel);
        Jedis jedis = new Jedis();

        if (count > 0) {
            jedis.del("logo", "address");
        }
        return ResultModel.getResultModel(count);
    }

    @Override
    public ResultModel update(CompanyModel companyModel) {

        int count = companyDao.update(companyModel);
        Jedis jedis = new Jedis();

        if (count > 0) {
            jedis.del("logo", "address");
        }
        return ResultModel.getResultModel(count);
    }

    @Override
    public ResultModel findAll(CompanyModel companyModel) {
        return null;
    }

    @Override
    public ResultModel findById(CompanyModel companyModel) {
        return null;
    }

    @Override
    public ResultModel getCount(CompanyModel companyModel) {
        return null;
    }

    @Override
    public ResultModel enable(CompanyModel companyModel) {
        return null;
    }
}
